<%--
    Document   : index
    Created on : 19 juin 2010, 23:51:05
    Author     : marya
--%>

<%@page contentType="text/xml" pageEncoding="UTF-8"%>
<%@page import="org.restlet.resource.ClientResource" %>
<%@page import="org.restlet.representation.Representation" %>
<%@page import="org.restlet.ext.xml.DomRepresentation" %>
<%@page import="org.w3c.dom.Element" %>
<%@page import="org.w3c.dom.Node" %>
<%@page import="org.w3c.dom.NodeList" %>
<%@page import="java.util.List" %>
<%@page import="xmlws.helpers.WebService" %>
<%
            request.setCharacterEncoding("UTF-8");
            response.setCharacterEncoding("UTF-8");
            ClientResource client = new ClientResource(WebService.federateur + "/groupes/" + request.getParameter("idGroupe") + "/contacts");

            DomRepresentation representation = new DomRepresentation(client.get());
            NodeList elements = representation.getDocument().getElementsByTagName("contact");
            if (elements.getLength() > 0) {
                for (int i = 0; i < elements.getLength(); i++) {
                    Node node = elements.item(i);
                    String[] tab = node.getAttributes().
                            getNamedItem("href").getTextContent().split("/");

                    String id = tab[tab.length - 1];
                    out.println("<div class='contact' onclick=\"getInfo_contact(" + id + " , " + request.getParameter("idGroupe")  + ")\">");
                    NodeList childs = node.getChildNodes();
                    for (int j = 0; j < childs.getLength(); j++) {
                        Node child = childs.item(j);
                        String childName = child.getNodeName();
                        if (childName.equals("prenom")) {
                            out.println(child.getTextContent());
                        } else if (childName.equals("nom")) {
                            out.println(" " + child.getTextContent());
                        }
                    }
                    out.println("</div><br/>");
                }
            }





%>

